package com.msos.service.phoneDeleteService;

import com.msos.dao.phoneDeleteDao.phoneDeleteDao;
import com.msos.dao.sendMsgDao.sendMsgDao;
import com.msos.model.customer.Customer;
import com.msos.utils.CommonsUtils;

import java.sql.SQLException;
import java.util.List;

public class phoneDeleteService {
    phoneDeleteDao phoDeleteDao=new phoneDeleteDao();
    sendMsgDao sendMsgdao=new sendMsgDao();

    Customer c=null;
    Integer r1=CommonsUtils.EXCEPTION;
    public Integer phoDelete(String[] numList, String flag) {
        if(flag=="only"){
            try {
                c = sendMsgdao.getCustomerByPho(numList[0]);
                if(c==null){
                    return CommonsUtils.NOTHING;
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
        try {
             r1= phoDeleteDao.deleteSelectPhos(numList);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return  r1==CommonsUtils.SUCCESS?CommonsUtils.SUCCESS:CommonsUtils.EXCEPTION;
    }

    public List<Customer> getAllCus() {
        try {
            return phoDeleteDao.getAllCus();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
